//
//  LoginBaseViewController.m
//  VoiceLive
//
//  Created by 凸阿滨 on 2017/10/24.
//  Copyright © 2017年 WB. All rights reserved.
//

#import "LoginBaseViewController.h"
#import "GlobalDefine.h"
@interface LoginBaseViewController ()

@end

@implementation LoginBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
    
}

#pragma 页面下滑动画
-(void)drapViewDown{
    [self.view endEditing:YES];
    NSTimeInterval animationDuration = 0.30f;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    CGRect rect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.height);
    self.view.frame = rect;
    
    [UIView commitAnimations];
}

#pragma 页面上滑滑动画
-(void)drapViewUp:(UITextField *)textField{
    CGRect frame = textField.frame;
    
    CGFloat heights = self.view.frame.size.height;
    // 当前点击textfield的坐标的Y值 + 当前点击textFiled的高度 - （屏幕高度- 键盘高度 - 键盘上tabbar高度）
    // 在这一部 就是了一个 当前textfile的的最大Y值 和 键盘的最全高度的差值，用来计算整个view的偏移量
    int offset = frame.origin.y + 42- ( heights - 216.0-35.0);//键盘高度216
    NSTimeInterval animationDuration = 0.30f;
    [UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    float width = self.view.frame.size.width;
    float height = self.view.frame.size.height;
    
    if(offset < 0)
        
    {
        CGFloat ofsetY = 0;
        if(IS_IPHONE_5){
            ofsetY = 568 / 4;
        }else{
            ofsetY = 70;
        }
        CGRect rect = CGRectMake(0.0f, -ofsetY ,width,height);
        
        self.view.frame = rect;
    }
    
    [UIView commitAnimations];
    
}
-(void) showHUD:(NSString*) text
{
    self.HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:_HUD];
    _HUD.delegate = self;
    _HUD.mode = MBProgressHUDAnimationFade;
    _HUD.labelText = @"";
    _HUD.detailsLabelText = text;
    [_HUD show:YES];
}



-(void) hideHUD
{
    if(_HUD != nil)
    {
        [_HUD removeFromSuperview];
        _HUD.delegate = nil;
        _HUD = nil;
    }
}

#pragma mark 提示框封装
- (void)alertMessage:(NSString *)message{
    
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:message message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alertVc addAction:action];
    [self presentViewController:alertVc animated:YES completion:nil];
    
}



@end
